// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------
// Modification history:
// feature: listener code decoupling
// feature: change E2E packet format
// feature: destination order support by reception timestamp
// feature: E2E New Requirement Development
// ------------------------------------------------------------------

#ifndef INCLUDE_EDDS_RTPS_ATTRIBUTES_READERATTRIBUTES_H_
#define INCLUDE_EDDS_RTPS_ATTRIBUTES_READERATTRIBUTES_H_

#include <edds/rtps/common/Time_t.h>
#include <edds/rtps/common/Guid.h>
#include <edds/rtps/attributes/EndpointAttributes.h>
#include <ertps/qos/QosPolicies.h>

#include <functional>

#include <ertps/utils/collections/ResourceLimitedContainerConfig.hpp>

#include <xmlparser/attributes/XMLReaderAttributes.h>
#include <deps/attributes/BaseReaderAttributes.h>

namespace evbs {
namespace ertps {
namespace rtps {

using ReaderTimes = vbsutil::xmlparser::ReaderTimes;

/**
 * Class ReaderAttributes, to define the attributes of a RTPSReader.
 * @ingroup RTPS_ATTRIBUTES_MODULE
 */
class ReaderAttributes : public vbs::BaseReaderAttributes {
 public:
    ReaderAttributes()
        : liveliness_kind_(AUTOMATIC_LIVELINESS_QOS),
          liveliness_lease_duration(TIME_T_INFINITE_SECONDS, TIME_T_INFINITE_NANOSECONDS),
          deadline(TIME_T_INFINITE_SECONDS, TIME_T_INFINITE_NANOSECONDS),
          disable_positive_acks(false),
          enable_e2e_protection(false),
          needCheckEnableFlag(false),
          e2e_p04_min_data_length(0U),
          e2e_p04_max_data_length(0U),
          e2e_p04_max_delta_counter(10U) {
        endpoint.endpointKind = READER;
        endpoint.durabilityKind = VOLATILE;
        endpoint.reliabilityKind = BEST_EFFORT;
        dest_order_reception = true;
    }

    virtual ~ReaderAttributes() {}

    //! Times associated with this reader (only for stateful readers)
    ReaderTimes times;

    //! Liveliness kind
    LivelinessQosPolicyKind liveliness_kind_;

    //! Liveliness lease duration
    Duration_t liveliness_lease_duration;
    Duration_t deadline;
    //! Disable positive ACKs
    bool disable_positive_acks;

    //! Enable the e2e protection
    bool enable_e2e_protection;
    bool needCheckEnableFlag;
    //! E2E Profile04
    uint16_t e2e_p04_min_data_length;
    uint16_t e2e_p04_max_data_length;
    uint16_t e2e_p04_max_delta_counter;

    //! Define the allocation behaviour for matched-writer-dependent collections.
    ResourceLimitedContainerConfig matched_writers_allocation;

    bool dest_order_reception;

    uint8_t trace_point_status = 0;
};

} /* namespace rtps */
} /* namespace ertps */
} /* namespace evbs */

#endif  // INCLUDE_EDDS_RTPS_ATTRIBUTES_READERATTRIBUTES_H_
